package com.wdm.sms.service.process.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wdm.sms.commonutil.config.inteceptor.springsecurity.custom.LoginUserInfoHelper;
import com.wdm.sms.entity.common.dto.process.ProcessRecord;
import com.wdm.sms.entity.system.SysUser;
import com.wdm.sms.mapper.OaProcessRecordMapper;
import com.wdm.sms.service.process.OaProcessRecordService;
import com.wdm.sms.service.user.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 审批记录 服务实现类
 * </p>
 *
 * @author atguigu
 * @since 2023-02-15
 */
@Service
public class OaProcessRecordServiceImpl extends ServiceImpl<OaProcessRecordMapper, ProcessRecord> implements OaProcessRecordService {

    @Autowired
    private SysUserService sysUserService;

    @Override
    public void record(Long processId, Integer status, String description) {
        String username = LoginUserInfoHelper.getUsername();
        SysUser user = sysUserService.getUserByUserName(username);
        SysUser sysUser = sysUserService.getById(user.getId());
        ProcessRecord processRecord = new ProcessRecord();
        processRecord.setProcessId(processId);
        processRecord.setStatus(status);
        processRecord.setDescription(description);
        processRecord.setOperateUser(sysUser.getName());
        processRecord.setOperateUserId(user.getId());
        baseMapper.insert(processRecord);
    }
}
